<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>同花顺个股看点</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">	
			p {margin:0px;font-size:14px;}					
			ul {margin:5px;font-size:16px;}			
			h4 {margin:5px}	
			.fixedBox{
				border: 5px solid #555555;				
				
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}			
		</style>		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script>
			window.onload = function() {
				getSource();
				changeStyle();
			}
						
			
			function changeStyle() {
				var obj = document.getElementById("towrite");				
				obj.style.left = "0px"; 				
				obj.style.width = "100%";	
				//obj.style.height = "620px";		
				obj.style.fontSize ="12px";					
			}
			
			
			$(function() {
				setInterval(function() {
					getSource();
				},
				500);
			})
			
			var gpdm = "";
			var gpmc = "";
			var dm ="";			
			function getSource() {				
				var div = document.getElementById('towrite');
				var gp = decodeURI(window.location.href).split('##');					
				gpdm = gp[1];
				gpmc = gp[2];		
				//alert(gpdm)
				if(dm != gpdm){
					temp = "";
					dm = gpdm;
					var sc = "";
					if(gpdm.substr(0 , 1) == "6"){				
						sc = "17";
					}else{					
						sc = "33";
					}			
					var url = "https://eq.10jqka.com.cn/open/api/stock_view_v2/homepage?stockCode=" + dm + "&marketId=" + sc;
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));							
							res = data.data.labels;	
						}
					});
					
					div.innerHTML = "<font size='3' style=color:#FFFF00;>同花顺个股看点：<font size='2' color=#fff>&nbsp;&nbsp;&nbsp;&nbsp;" + gpdm + "&nbsp;&nbsp;" + gpmc + "</font></font>";
					//alert(JSON.stringify(res))
					
					var scyx = [];   //市场印象
					var a1 = res.findIndex((v) => {   
						return v.tag_name ===  "市场印象";
					});
					if(a1 > -1){
						var arrfind = res.find(function (item) {
							return item.tag_name == "市场印象"
						});
						scyx = arrfind.sustain_tags; 
						
						var transform_aa = [           
						{"tag":"p", children:function(){return(json2html.transform(this, transform_bb));}}
						];
						
						var transform_bb=												
						{"tag":"ul", children:[									
						{"tag": "p  style='color:#FFD700;'", "html":"${name}"},									
						]};
					
						var html = json2html.transform(scyx, transform_aa);
						//div.innerHTML += "<h4 style='color:#E1FFFF;'>市场印象</h4>" + html;
						var name = "<a style='color:#E1FFFF;font-size:16px' href='javascript:void(0)' onclick='update(\"市场印象\")'>市场印象（" + scyx.length + "）</a>"
						div.innerHTML += "<h4 style='margin-left:5px;'>" + name + "</h4>";	
						
						var newDiv = document.createElement("div");
						newDiv.id = '市场印象';
						newDiv.style.display = "none";						
						newDiv.innerHTML = html;
						div.appendChild(newDiv);											
					}
					
					var gpfg = [];   //股票投资风格
					var a2 = res.findIndex((v) => {   
						return v.tag_name ===  "股票投资风格";
					});
					if(a2 > -1){
						var arrfind = res.find(function (item) {
							return item.tag_name == "股票投资风格"
						});
						gpfg = arrfind.sustain_tags; 
						
						var transform_aa = [           
						{"tag":"p", children:function(){return(json2html.transform(this, transform_bb));}}
						];
						
						var transform_bb=												
						{"tag":"ul", children:[									
						{"tag": "p style=color:#FFD700;", "html":"${name}"},									
						]};
					
						var html = json2html.transform(gpfg, transform_aa);	
						//div.innerHTML += "<h4 style='color:#E1FFFF;'>股票投资风格</h4>" + html;
						var name = "<a style='color:#E1FFFF;font-size:16px' href='javascript:void(0)' onclick='update(\"股票投资风格\")'>股票投资风格（" + gpfg.length + "）</a>"
						div.innerHTML += "<h4 style='margin-left:5px;'>" + name + "</h4>";	
						
						var newDiv = document.createElement("div");
						newDiv.id = '股票投资风格';
						newDiv.style.display = "none";						
						newDiv.innerHTML = html;
						div.appendChild(newDiv);		
					} 
					
					var gplh = [];   //利好
					for(var i = 0; i < res.length; i++){
						if(res[i].tag_name != "市场印象" && res[i].tag_name != "股票投资风格"){
							if(res[i].level == "利好"){
								gplh.push(res[i]);
							}
						}					
					}
					if(gplh.length > 0){
						var transform_aa = [           
						{"tag":"p", children:function(){return(json2html.transform(this, transform_bb));}}
						];
						
						var transform_bb=												
						{"tag":"ul", children:[									
						{"tag": "li style=color:#FFD700;", "html":"${tag_name}（${update_time}）"},
						{"tag": "p style=color:#FFFFF0;", "html":"${summary}"},
						{"tag":"p style=color:#FFA500;", children:function(){
							if(this.sustain_tags != null){
								return(json2html.transform(this.sustain_tags, transform_cc));
							}
						}}
						]};
						
						var transform_cc=												
						{"tag":"ul", children:[									
						{"tag": "p style=color:#FFDEAD;", "html":"${name}"},						
						]};
						
						var html = json2html.transform(gplh, transform_aa);	
						//div.innerHTML += "<h4 style='color:#FF4500;'>利好</h4>" + html;
						var name = "<a style='color:#FF4500;font-size:16px' href='javascript:void(0)' onclick='update(\"利好\")'>利好（" + gplh.length + "）</a>"
						div.innerHTML += "<h4 style='margin-left:5px;'>" + name + "</h4>";	
						
						var newDiv = document.createElement("div");
						newDiv.id = '利好';
						newDiv.style.display = "block";						
						newDiv.innerHTML = html;
						div.appendChild(newDiv);
						temp += "利好;";
					}
					
					var gplk = [];   //利空
					for(var i = 0; i < res.length; i++){
						if(res[i].tag_name != "市场印象" && res[i].tag_name != "股票投资风格"){
							if(res[i].level == "利空"){
								gplk.push(res[i]);
							}
						}					
					}
					if(gplk.length > 0){
						var transform_aa = [           
						{"tag":"p", children:function(){return(json2html.transform(this, transform_bb));}}
						];
						
						var transform_bb=												
						{"tag":"ul", children:[									
						{"tag": "li style=color:#FFD700;", "html":"${tag_name}（${update_time}）"},
						{"tag": "p style=color:#FFFFF0;", "html":"${summary}"},
						{"tag":"p style=color:#FFA500;", children:function(){
							if(this.sustain_tags != null){
								return(json2html.transform(this.sustain_tags, transform_cc));
							}
						}}
						]};
						
						var transform_cc=												
						{"tag":"ul", children:[									
						{"tag": "p style=color:#FFDEAD;", "html":"${name}"},						
						]};
						
						var html = json2html.transform(gplk, transform_aa);	
						//div.innerHTML += "<h4 style='color:#00FF00;'>利空</h4>" + html;
						var name = "<a style='color:#00FF00;font-size:16px' href='javascript:void(0)' onclick='update(\"利空\")'>利空（" + gplk.length + "）</a>"
						div.innerHTML += "<h4 style='margin-left:5px;'>" + name + "</h4>";	
						
						var newDiv = document.createElement("div");
						newDiv.id = '利空';
						newDiv.style.display = "block";						
						newDiv.innerHTML = html;
						div.appendChild(newDiv);
						temp += "利空;";
					}
					
					var gpzx = [];   //中性
					for(var i = 0; i < res.length; i++){
						if(res[i].tag_name != "市场印象" && res[i].tag_name != "股票投资风格"){
							if(res[i].level == "中性"){
								gpzx.push(res[i]);
							}
						}					
					}
					if(gpzx.length > 0){
						var transform_aa = [           
						{"tag":"p", children:function(){return(json2html.transform(this, transform_bb));}}
						];
						
						var transform_bb=												
						{"tag":"ul", children:[									
						{"tag": "li style=color:#FFD700;", "html":"${tag_name}（${update_time}）"},
						{"tag": "p style=color:#FFFFF0;", "html":"${summary}"},
						{"tag":"p style=color:#FFA500;", children:function(){
							if(this.sustain_tags != null){
								return(json2html.transform(this.sustain_tags, transform_cc));
							}
						}}
						]};
						
						var transform_cc=												
						{"tag":"ul", children:[									
						{"tag": "p style=color:#FFDEAD;", "html":"${name}"},						
						]};
						
						var html = json2html.transform(gpzx, transform_aa);	
						//div.innerHTML += "<h4 style='color:#00FF00;'>中性</h4>" + html;
						var name = "<a style='color:#FFF;font-size:16px' href='javascript:void(0)' onclick='update(\"中性\")'>中性（" + gpzx.length + "）</a>"
						div.innerHTML += "<h4 style='margin-left:5px;'>" + name + "</h4>";	
						
						var newDiv = document.createElement("div");
						newDiv.id = '中性';
						newDiv.style.display = "none";						
						newDiv.innerHTML = html;
						div.appendChild(newDiv);		
					}
					
					div.scrollTop = 0; //回到顶部
				}
			}
			
			var temp = "";	
			function update(ss) {
				if(document.getElementById(ss)){					
					var div = document.getElementById(ss);
					if(temp.indexOf(ss) == -1){
						temp += ss + ";";
						div.style.display = "block";
					}else{
						temp = temp.replace(ss + ";" , "");
						div.style.display = "none";
					}
				}											
			}
			
		</script>
	</head>
	<body>
		<div id="towrite" class="fixedBox"></div>		
	</body>
</html>